import {fetch} from '@/utils/fetch'

export const getAuth = async () => {
  let res = await fetch({
    query: `{
      getCosAuth {
        credentials {
          sessionToken
          tmpSecretId
          tmpSecretKey
        }
        expiredTime
      }
    }`,
    cache: false
  })

  let cosAuth = {
    sessionToken: res.data.getCosAuth.credentials.sessionToken,
    tmpSecretId: res.data.getCosAuth.credentials.tmpSecretId,
    tmpSecretKey: res.data.getCosAuth.credentials.tmpSecretKey,
    expiredTime: res.data.getCosAuth.expiredTime
  }

  return cosAuth
}
